<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise封装AJAX操作</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
    /**
     *
     * @param url {String}
     */
    function sendAjax(url) {
        return new Promise((resolve, reject) => {
            $.ajax({
                url: url,
                data: "",
                type: "GET",
                success: function (data) {
                    resolve(data);
                },
                dataType: "json"
            });
        });
    }

    sendAjax("https://api.apiopen.top/api/sentences").then(val=>{
        console.log(val);
    },err=>{

    });
</script>
</body>
</html>